import {$http} from '@escook/request-miniprogram'
uni.$http = $http
// 通过环境来判断
if(process.env.NODE_ENV === 'development'){
  // $http.baseUrl = 'http://localhost:5173/api' 
  $http.baseUrl = 'https://apifoxmock.com/m1/4728220-0-default'
}else{
  $http.baseUrl = 'https://apifoxmock.com/m1/4728220-0-default'
}
// $http.baseUrl = 'https://apifoxmock.com/m1/4728220-0-default'
// 请求拦截器
$http.beforeRequest = function(options){
  options.header = {
    token:uni.getStorageInfoSync('token') || ''
  }

  uni.showLoading({
    title:'数据加载中...'
  })
}
// 响应拦截器
$http.afterRequest = function(options){
console.log('响应拦截器：',options);
if(options.data.code === 1){
  console.log('请求成功');
}
  uni.hideLoading()
}